﻿using System;
using System.Data;
using CuoiHoi.Business;

namespace CuoiHoi
{
    public partial class MenuNgang : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void MenuDong(string idTheLoaiCha)
        {
            DataTable table = new DataTable();
            table = BTheLoai.SelectByidTheLoaiCha(idTheLoaiCha);
            int count = table.Rows.Count;

            if (count > 0 && idTheLoaiCha != "0")
                Response.Write("<ul class='dropdown-menu'>");

            for (int i = 0; i < count; i++)
            {
                if (idTheLoaiCha == "0" && BTheLoai.SelectByidTheLoaiCha(table.Rows[i]["idTheLoai"].ToString()).Rows.Count>0)
                    Response.Write("<li class='dropdown'><a rel='nofollow' class='dropdown-toggle'  href='/" + Router.NonUnicode(table.Rows[i]["TenTheLoai"].ToString()) + "-" + table.Rows[i]["DuongDan"].ToString() + Router.NonUnicode(table.Rows[i]["idTheLoai"].ToString()) + "'>" + table.Rows[i]["TenTheLoai"].ToString() + " <b class='caret'></b></a>");
                else
                    Response.Write("<li><a rel='nofollow' href='/" + Router.NonUnicode(table.Rows[i]["TenTheLoai"].ToString()) + "-" + table.Rows[i]["DuongDan"].ToString() + Router.NonUnicode(table.Rows[i]["idTheLoai"].ToString()) + "'>" + table.Rows[i]["TenTheLoai"].ToString() + "</a>");

                MenuDong(table.Rows[i]["idTheLoai"].ToString());
            }

            if (count > 0) Response.Write("</ul></li>");
            else Response.Write("</li>");
        }
    }
}